/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, {Component} from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    Button,
    View
} from 'react-native';
import DBUtils, {PTest} from '../filter/common/DBUtils'


const instructions = Platform.select({
    ios: 'Press Cmd+R to reload,\n' +
        'Cmd+D or shake for dev menu',
    android: 'Double tap R on your keyboard to reload,\n' +
        'Shake or press menu button for dev menu',
});
let dBUtils = new DBUtils(PTest);
export default class App extends Component {
    render() {
        return (
            <View style={styles.container}>
                <Button title={'写入'} onPress={() => {
                    dBUtils._write(PTest, {name: '12321'});
                }}/>
                <Button title={'读取'} onPress={() => {
                    alert(JSON.stringify(dBUtils._query(PTest)));
                }}/>
                <Button title={'清空'} onPress={() => {
                    dBUtils._clearAll(PTest);
                }}/>
                <Button title={'删除一个'} onPress={() => {
                    dBUtils._del(PTest, {name: '12321'});
                }}/>
                <Text style={styles.welcome}>
                    Welcome to React Native!
                </Text>
                <Text style={styles.instructions}>
                    To get started, edit App.js
                </Text>
                <Text style={styles.instructions}>
                    {instructions}
                </Text>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
});
